<template>
  <section class="page-com" id="page" ref="page">
    <!-- 头部导航栏 -->
    <HeaderCom class="student-head-com" />
    <div class="bannerBox">
      <img src="../../assets/images/student/banner.png" class="banner" />
    </div>
    <img
      src="../../assets/images/student/upTop.png"
      class="upTop"
      @click="upTop"
      id="upTop"
    />
    <div class="content-page">
      <div class="left" id="leftMenu">
        <div class="row">
          <div class="title">
            <img src="../../assets/images/cultivate/menu.png" class="icon" />
            学生风采
          </div>
          <div
            class="row_li"
            :class="activeIndex == i ? 'active' : ''"
            v-for="(it, i) in list"
            :key="i"
            @click="openFun({i})"
          >
            {{ it }}
          </div>
        </div>
      </div>
      <div class="right">
        <div class="steps">
          <span @click="$router.push({ name: 'home' })">首页></span>
          <span>学生风采></span>
          <span>{{ list[activeIndex] }}</span>
        </div>
        <div class="item" v-for="(item, index) in studentList" :key="index">
          <div class="item_top">
            <div class="name">{{ item.title }}</div>
            <div class="title">{{ item.subtitle }}</div>
          </div>
          <div class="item_bottom">
            <div class="content">{{ item.context }}</div>
            <img :src="item.imageUrl" v-if="item.imageUrl && !item.videoUrl" />
            <div class="video" v-if="item.videoUrl">
              <!-- <vueMiniPlayer 
              :video="item.videoUrl"
              :mutex="true"
              ></vueMiniPlayer> -->
              <video :src="item.videoUrl" controls></video>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="mobile-student-style">
      <div class="style-nav">
        <div class="style-nav-wrap">
          <div
            class="style-item"
            :class="activeIndex == i ? 'active' : ''"
            v-for="(item, i) in list"
            :key="i"
            @click="openFun({ i })"
          >
            {{ item }}
          </div>
        </div>
      </div>
      <div class="style-content">
        <van-empty
          v-if="studentList.length <= 0"
          class="custom-image"
          image="https://img.yzcdn.cn/vant/custom-empty-image.png"
          description="暂无数据"
        />
        <div
          class="style-content-wrap"
          v-for="(item, index) in studentList"
          :key="index"
        >
          <div class="content-left">
            <img :src="item.imageUrl" v-if="item.imageUrl && !item.videoUrl" />
            <div class="video" v-if="item.videoUrl">
              <video :src="item.videoUrl" controls></video>
            </div>
          </div>
          <div class="content-right"  :class="item.unfold ? 'content-right-active': ''">
            <div class="name">{{ item.title }}</div>
            <div class="title">{{ item.subtitle }}</div>
            <div class="content" :class="item.unfold ? 'content-active': ''">{{ item.context }}</div>
            <div class="unfold" v-if="!item.unfold" @click="unfoldContent(item)">展开</div>
          </div>
        </div>
      </div>
    </div>
    <div class="mainFooter" id="pageFooter">
      <FooterMenu />
    </div>
  </section>
</template>

<script>
import Vue from "vue";
import FooterMenu from "@/components/footerMenu/index.vue";
import HeaderCom from "@/components/header";
// import vueVideoPlayer from "@/components/videoPlayer/videoPlayer.vue";
import vueMiniPlayer from "vue-mini-player";
import "vue-mini-player/lib/vue-mini-player.css";
Vue.use(vueMiniPlayer);
import { getStudentShow } from "../../request/api";
import { Empty } from "vant";
Vue.use(Empty);
export default {
  // 组件名称
  name: "demo",
  // 组件参数 接收来自父组件的数据
  props: {},
  // 局部注册的组件
  components: { HeaderCom, FooterMenu },
  // 组件状态值
  data() {
    return {
      swiper: null,
      studentList: [],
      list: ["团队采访", "风采展示", "企业点评"],
      activeIndex: 0,
      total: 0,
    };
  },
  // 计算属性
  computed: {},
  // 侦听器
  watch: {},
  // 组件方法
  methods: {
    getDataList(list, index) {
      if (list.length <= 0) return [];
      let newList = [];
      newList[0] = list.filter((v) => v.abstracts == "0") || [];
      newList[1] = list.filter((v) => v.abstracts == "1") || [];
      newList[2] = list.filter((v) => v.abstracts == "2") || [];
      return newList[index];
    },
    init(index = 0) {
      getStudentShow({ pageNo: 1, pageSize: 100}).then(res=> {
        if(res.data&&res.data.list){
          this.studentList = this.getDataList(res.data.list, index);
          this.studentList.map((item) => {
            item.unfold = true;
            if (item.context.length > 57) item.unfold = false;
            return item;
          })
        }
      })
      this.upTop();
    },
    unfoldContent(item) {
      item.unfold = !item.unfold;
      this.$forceUpdate();
    },
    openFun(idx) {
      let index = idx.i;
      if (this.activeIndex == index) return;
      this.activeIndex = index;
      this.init(index);
    },
    upTop() {
      window.scrollTo(0, 0);
    },
    menuHidden() {
      let leftMenu = document.getElementById("leftMenu"),
        upTop = document.getElementById("upTop"),
        footEl = document.getElementById("pageFooter");
      let cb =
          window.innerHeight -
          leftMenu.getBoundingClientRect().y -
          leftMenu.getBoundingClientRect().height,
        cb2 =
          window.innerHeight -
          upTop.getBoundingClientRect().y -
          upTop.getBoundingClientRect().height;
      let footElCb = window.innerHeight - footEl.getBoundingClientRect().y;
      if (footElCb >= cb) {
        leftMenu.style = "opacity: 0";
      } else {
        leftMenu.style = "opacity: 1";
      }
      if (footElCb >= cb2) {
        upTop.style = "opacity: 0";
      } else {
        upTop.style = "opacity: 1";
      }
    },
  },
  created() {},
  mounted() {
    this.init();
    this.$nextTick(() => {
      window.addEventListener("scroll", this.menuHidden);
    });
  },
  beforeDestory() {
    window.removeEventListener("scroll", this.menuHidden);
  },
};
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="less" scoped>
.page-com {
  position: relative;
  width: 100%;
  background: rgb(237, 242, 249);
  padding-top: 80px;
  .upTop {
    width: 46px;
    position: fixed;
    bottom: 107px;
    right: calc((100% - 1200px) / 2 - 78px);
    cursor: pointer;
    transition-duration: 0.3s;
  }
  .bannerBox {
    width: 100%;
    position: relative;
    height: 265px;
    margin-bottom: 44px;
    overflow-x: hidden;
    .banner {
      width: 100%;
      -o-object-fit: contain;
      object-fit: contain;
      height: 265px;
      display: block;
      min-width: 1920px;
      position: absolute;
      left: 50%;
      transform: translateX(-50%);
      z-index: 2;
    }
    &::after {
      content: "";
      height: 220px;
      position: absolute;
      top: 0;
      z-index: 1;
      background: rgb(229, 235, 246);
      width: 100%;
      left: 0;
    }
  }
}
.content-page {
  position: relative;
  margin: 0 auto;
  width: 1200px;
  min-height: calc(100vh - 67px);
  padding-left: 230px;
  .right {
    .steps {
      width: 100%;
      font-size: 18px;
      font-family: AlibabaPuHuiTi_2_45_Light;
      font-weight: 400;
      color: #16539a;
      line-height: 18px;
      margin-bottom: 16px;
      text-align: right;
      span {
        &:first-child {
          cursor: pointer;
        }
      }
    }
    .item {
      width: 100%;
      margin-bottom: 30px;
      background: #fff;
      font-family: AlibabaPuHuiTi_2_35_Thin;
      border-top: 1px rgb(230, 230, 230) solid;
      border-bottom: 1px rgb(230, 230, 230) solid;
      font-weight: 400;
      .item_top {
        width: 100%;
        height: 100px;
        padding: 20px 48px;
        border-bottom: 1px rgb(230, 230, 230) solid;
        color: #000000;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        .name {
          width: 100%;
          font-size: 24px;
          line-height: 30px;
          // margin-bottom: 10px;
        }
        .title {
          width: 100%;
          font-size: 16px;
          line-height: 18px;
        }
      }
      .item_bottom {
        width: 100%;
        padding: 22px 48px 26px;
        .content {
          font-size: 18px;
          color: #686868;
          line-height: 22px;
          margin-bottom: 20px;
          text-align: justify;
        }
        img {
          height: 220px;
          display: block;
        }
        .video {
          width: 517px;
          height: 300px;
          position: relative;
          /deep/ .vjs-fluid {
            height: 100% !important;
          }
          video {
            width: 100%;
            height: 100%;
          }
        }
      }
    }
  }
  .left {
    width: 240px;
    position: fixed;
    left: calc((100% - 1200px) / 2 - 70px);
    top: 160px;
    box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.18);
    padding-top: 48px;
    padding-left: 20px;
    background: #fff;
    border-radius: 8px;
    transition: all 0.6s;
    opacity: 1;
    z-index: 5;
    .row {
      width: 100%;
      font-size: 15px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #37383d;
      line-height: 21px;
      // height: 52px;
      transition-duration: 0.3s;
      overflow-y: hidden;
      &:hover {
        height: auto;
        .title {
          border-bottom: 1px solid #d4d6da;
          .icon2 {
            transform: rotate(90deg);
          }
        }
      }
      .title {
        margin-bottom: 35px;
        padding-left: 40px;
        padding-bottom: 30px;
        position: relative;
        font-weight: bold;
        border-bottom: 1px solid #d4d6da;
        .icon {
          position: absolute;
          left: 0;
          top: 0;
          max-width: 20px;
        }
        .icon2 {
          position: absolute;
          right: 20px;
          height: 20px;
          transition-duration: 0.3s;
          top: 0;
        }
      }
      .row_li {
        width: calc(100% - 20px);
        padding-left: 44px;
        cursor: pointer;
        height: 44px;
        position: relative;
        margin-bottom: 38px;
        border-radius: 8px;
        display: flex;
        align-items: center;
        transition-duration: 0.3s;
        .row_li_icon {
          position: absolute;
          left: 13px;
          top: 50%;
          transform: translateY(-50%);
          max-width: 20px;
        }
        &:last-child {
          .row_li_icon {
            width: 17px;
          }
        }
        &:hover,
        &.active {
          color: #15539a;
          background: #e1f2fd;
          font-size: 16px;
          font-weight: 600;
          // border: 1px solid #daebff;
        }
      }
    }
  }
}

@media screen and (min-height: 950px) {
  .left {
    top: 421px !important;
  }
}
@media screen and (max-height: 820px) {
  .row_li {
    margin-bottom: 10px !important;
  }
}
@media (min-width: 769px) {
  .mobile-student-style {
    display: none;
  }
}
@media (max-width: 768px) {
  .header-com,
  .bannerBox,
  .upTop,
  .content-page {
    display: none;
  }
  .page-com {
    padding-top: 0;
    background: #ffffff;
  }
  .student-head-com {
    position: relative;
    z-index: 9999;
  }
  .style-nav {
    width: 100%;
    overflow: scroll;
    position: fixed;
    top: 0.54rem;
    left: 0;
    background-color: #fff;
    z-index: 99;
    .style-nav-wrap {
      display: flex;
      padding: 0.12rem 0 0.12rem 0.1rem;
      .style-item {
        width: 0.76rem;
        height: 0.31rem;
        text-align: center;
        font-size: 0.13rem;
        line-height: 0.31rem;
        border-radius: 0.16rem;
        color: #3d6cb0;
        background-color: rgba(61, 108, 176, 0.1);
        margin-right: 0.1rem;
      }
      .active {
        color: #ffffff;
        background-color: #3d6cb0;
      }
    }
  }
  .style-content {
    padding: 1.09rem 0 0.4rem;
    .style-content-wrap {
      display: flex;
      border-bottom: 1px solid #e6e6e6;
      padding: .15rem 0 0.15rem;
      margin: 0 0.1rem;
      .content-left {
        width: 1.07rem;
        height: auto;
        margin-right: 0.1rem;
        display: flex;
        img {
          width: 100%;
          height: 0.94rem;
          object-fit: cover;
        }
        .video {
          height: 0.94rem;
          video {
            width: 100%;
            height: 100%;
          }
        }
      }
      .content-right {
        flex: 1;
        font-size: 0.1rem;
        color: #37383d;
        line-height: 0.14rem;
        padding-bottom: 0.2rem;
        position: relative;
        .name {
          font-size: 0.14rem;
          font-weight: 500;
          line-height: 0.2rem;
        }
        .title {
          margin: 0.08rem 0 0.1rem;
        }
        .content {
          height: 0.42rem;
          font-size: 0.1rem;
          color: #9597A0;
          line-height: 0.14rem;
          -webkit-line-clamp: 3;
          display: -webkit-box;
          -webkit-box-orient: vertical;
          overflow: hidden;
          text-overflow: ellipsis;
        }
        .content-active {
          height: auto;
          -webkit-line-clamp: 9999;
        }
        .unfold {
          position: absolute;
          font-size: 0.12rem;
          line-height: 0.15rem;
          color: #3d6cb0;
          right: 0;
          bottom: 0;
        }
      }
      .content-right-active {
        padding-bottom: 0;
      }
    }
  }
}
</style>
